Send Conversation (OpenAI) (Generative Models)

Synopsis

Sends a full conversation for OpenAI for getting responses.

Description

This operator sends a conversation to OpenAI (ChatGPT, a different OpenAI model or even a finetuned variant of their models) or the equivalent models hosted by Microsoft Azure. The answer to the conversation will be delivered as a new table including information about token usage. Please note that you will need an account with OpenAI and an API key which you will need to provide as a Dictionary Connection as the second operator input. You may also need to buy credits since OpenAI only allows a few queries for free. You can select one of the models or simply enter the model ID of a model that you have finetuned yourself. If you select Azure as type, you will need to provide a connection to Azure Open AI instead. This dictionary connection needs to contain the 'api_key' as well as the 'api_base_url' of your Azure OpenAI environment. Please refer to the Azure OpenAI documentation for additional information.

Input

  • data (Data table)

    The data with the conversation so far. Needs at least two columns for the role and the content of all messages.

  • connection (Connection)

    A Dictionary Connection with only one key-value-pair with the key being 'api_key' and the value a valid OpenAI API key.

Output

  • data (Data table)

    The resulting data set where the conversation answer is added as a new row at the end of to the input data.

  • connection (Connection)

    The input connection.

Parameters

  • type Indicates if this operator should use an OpenAI model or a model hosted by Microsoft Azure.
  • model Select a model which should be used for this application. You can type also the model ID of a previously finetuned model instead.
  • role column The data column containing the values for the roles of each message. Roles can be "system", "user", or "assistant".
  • content column The name of the column which contains the content of each message.
  • max target tokens The maximum number of tokens which will be generated by the model.
  • number of answers Indicates if more than one answer vartiant is desired in which case the resulting data set will contain multiple rows. The token usage values will be the same total numbers for all answers.
  • temperature Controls the randomness used in the answers. Lower values will lead to less random answers. A temperature of 0 represents a fully deterministic model behavior.
  • top p Controls diversity via nucleus sampling. A value of 0.5 means that half of all likelihood-weighted options would be considered.
  • frequency penalty How much to penalize new tokens based on their frequency in the answer so far.
  • presence penalty How much to penalize new tokens based on their presence in the answer so far. Increases the model's likeliness to talk about new topics.
  • conda environment The conda environment used for this downloading task. Additional packages may be installed into this environment, please refer to the extension documentation for additional details on this and on version requirements for Python and some packages which have be present in this environment.

Tutorial Processes

Send a Conversation to Open AI

This process simply generates a data set with a short conversation. It then asks ChatGPT for the answer of the question in the last row. The answer will be added as an additional row to the import data. IMPORTANT: you will need an account with OpenAI and provide your own API key as a Dictionary Connection to make this tutorial process work.